<?php

/* кодировка в iconv зависит от локали ftp-сервера */

if ($_GET['music'] and $_GET['dir']) {
    $file = iconv("UTF-8", "CP1251", $_GET['dir']."/".$_GET['music']);
    $conn_id = ftp_connect("localhost");
    if (@ftp_login($conn_id, $_SESSION['LOGIN_NAME'], $_SESSION['LOGIN_PASS'])) {
        if (ftp_delete($conn_id, $file)) {
            ftp_close($conn_id);
            header("Location: " . $_SERVER['HTTP_REFERER']);
        }
        else {
            ftp_close($conn_id);
            header("Location: http://" . $SITE . "/?action=error");
        }
    }
    else {
        header("Location: http://" . $SITE . "/?action=error");
    }
}
else {
    header("Location: http://" . $SITE . "/?action=error");
}

?>
